﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace ArithmeticDemo
{
    public class LeeCode283
    {
        public void Start() {
            int[] nums = { 0, 1, 0, 3, 12 };
            //int[] nums = { 0, 0,  1 };
            MoveZeroes(nums);
            foreach (var item in nums) {
                Console.WriteLine(item);
            }
        }
        public void MoveZeroes(int[] nums) {
            int left = 0, right = nums.Length - 1;
            while (left < right) {
                if (nums[left] == 0) {
                    for (int i = left; i < right; i++) {
                        nums[i] = nums[i + 1];
                    }
                    nums[right] = 0;
                    right--;
                } else {
                    left++;
                }

            }
        }
    }
}
